local mouPaoxiao = fk.CreateSkill({
  name = "klmou__paoxiao",
  tags = { Skill.Compulsory },
})

Fk:loadTranslationTable{
  ["klmou__paoxiao"] = "咆哮",
  [":klmou__paoxiao"] = "锁定技，你使用【杀】无次数限制。若你装备了武器牌，你使用【杀】无距离限制。"..
  "你的出牌阶段，若你于当前阶段内使用过【杀】，你于此阶段使用【杀】具有以下效果：<br>①此【杀】指定的目标本回合非锁定技失效；"..
  "<br>②此【杀】不可被响应且伤害值+1；<br>③此【杀】对一名角色造成伤害后若其未死亡，你选择一项：1.失去1点体力；2.随机弃置一张牌。",

  ["@@klmou__paoxiao-turn"] = "咆哮封技",
  ["klmou__paoxiao-card"] = "随机弃置一张牌",
  ["klmou__paoxiao-hp"] = "失去1点体力",

  ["$klmou__paoxiao1"] = "百万军中，看我取上将首级！",
  ["$klmou__paoxiao2"] = "丈八蛇矛在吾手，汝等害怕了吗？",
}

mouPaoxiao:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return
      player:hasSkill(mouPaoxiao.name) and
      target == player and
      player.phase == Player.Play and
      data.card.trueName == "slash" and
      #player.room.logic:getEventsOfScope(GameEvent.UseCard, 2, function(e)
        return e.data.from == player and e.data.card.trueName == "slash"
      end, Player.HistoryPhase) > 1
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = data.to
    room:addPlayerMark(to, "@@klmou__paoxiao-turn")
    room:addPlayerMark(to, MarkEnum.UncompulsoryInvalidity .. "-turn")
    data.additionalDamage = (data.additionalDamage or 0) + 1
    data.disresponsive = true
    data.extra_data = data.extra_data or {}
    data.extra_data.klmou__paoxiao_user = player.id
  end,
})

mouPaoxiao:addEffect(fk.Damage, {
  is_delay_effect = true,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    if not player.dead and not data.to.dead and player.room.logic:damageByCardEffect() then
      local e = player.room.logic:getCurrentEvent():findParent(GameEvent.CardEffect)
      if e then
        local use = e.data
        return (use.extra_data or {}).klmou__paoxiao_user == player.id
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = table.filter(player:getCardIds("he"), function(id) return not player:prohibitDiscard(Fk:getCardById(id)) end)
    if #cards > 0 then
      local choice = room:askToChoice(player, {
        choices = {"klmou__paoxiao-card", "klmou__paoxiao-hp"},
        prompt = "咆哮，你须失去1点体力或随机弃置一张牌",
        cancelable = false,
        skill_name = mouPaoxiao.name,
      })
      if choice == "klmou__paoxiao-hp" then
        room:loseHp(player, 1, mouPaoxiao.name)
      else
        room:throwCard(table.random(cards, 1), mouPaoxiao.name, player, player)
      end
    end
  end,
})

mouPaoxiao:addEffect("targetmod", {
  bypass_times = function(self, player, skill, scope)
    return player:hasSkill(mouPaoxiao.name) and skill.trueName == "slash_skill" and scope == Player.HistoryPhase
  end,
  bypass_distances = function(self, player, skill, card, to)
    return player:hasSkill(mouPaoxiao.name) and skill.trueName == "slash_skill" and #player:getEquipments(Card.SubtypeWeapon) > 0
  end,
})

return mouPaoxiao
